Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prompt-sync

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prompt-sync

a synchronous prompt for node.js

  • 4.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is prompt-sync?

The prompt-sync npm package is a simple, synchronous way to get user input from the command line in Node.js applications. It is particularly useful for small scripts and command-line tools where asynchronous input handling is not necessary.

What are prompt-sync's main functionalities?

Basic Input

This feature allows you to prompt the user for input and capture their response synchronously. The example code asks the user for their name and then greets them.

const prompt = require('prompt-sync')();
const name = prompt('What is your name? ');
console.log(`Hello, ${name}!`);

Default Values

You can provide a default value that will be used if the user simply presses Enter without typing anything. The example code asks for the user's favorite color and defaults to 'blue' if no input is provided.

const prompt = require('prompt-sync')();
const color = prompt('What is your favorite color? ', 'blue');
console.log(`Your favorite color is ${color}.`);

Hidden Input

This feature allows you to hide the user's input, which is useful for sensitive information like passwords. The example code prompts the user for a password and masks the input with asterisks.

const prompt = require('prompt-sync')();
const password = prompt('Enter your password: ', {echo: '*'});
console.log('Password received.');

Other packages similar to prompt-sync

Keywords

FAQs

Package last updated on 20 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc